package com.eastfair.projectcore.service.impl;

import cn.hutool.core.util.RandomUtil;
import com.eastfair.core.context.ContextConstants;
import com.eastfair.core.utils.NetUtils;
import com.eastfair.projectcore.dao.WorkerNodeMapper;
import com.eastfair.projectcore.entity.ProjectDb;
import com.eastfair.projectcore.entity.WorkerNode;
import com.eastfair.projectcore.service.WorkerNodeService;
import com.eastfair.boot.service.SuperServiceImpl;

import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.eastfair.constant.BusinessConstant;
import com.eastfair.core.base.R;

import java.util.Collection;

//import com.baomidou.dynamic.datasource.annotation.DS;
import org.springframework.web.bind.annotation.PostMapping;

/**
 * <p>
 * 业务实现类
 * DB 雪花id的 WorkerID
 * </p>
 *
 * @author ligang
 * @date 2022-02-25
 */
@Slf4j
@Service
public class WorkerNodeServiceImpl extends SuperServiceImpl<WorkerNodeMapper, WorkerNode> implements WorkerNodeService {

    /**
     * 处理新增相关处理
     *
     * @param model 实体
     * @return 是否成功
     */
    @Override
    protected R<Boolean> handlerSave(WorkerNode model) {
//        model = new WorkerNode();
//        model.setHostName(NetUtils.getLocalAddress());
//        //暂时随机给端口
//        model.setPort(System.currentTimeMillis() + "-" + RandomUtil.randomInt(100000));
        return R.successDef();
    }


    /**
     * 创建worknode
     *
     * @return
     */
    @Override
    public Long createFunction() {
//        WorkerNode workerNode = new WorkerNode();
//        this.save(workerNode);
        return 0L;
    }

}
